package cn.hist.hfp.converter;

import cn.hist.hfp.entity.Species;
import cn.hist.hfp.vo.SpeciesVO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Component
public class SpeciesConverter {

    public SpeciesVO convert(Species species) {
        return SpeciesVO.builder().id(species.getId())
                .name(species.getName())
                .description(species.getDescription()).build();
    }

    public List<SpeciesVO> convert(List<Species> species) {
        List<SpeciesVO> speciesVOS = new ArrayList<>();
        for (Species s: species) {
            speciesVOS.add(convert(s));
        }
        return speciesVOS;
    }

    public Set<SpeciesVO> convert(Set<Species> species) {
        Set<SpeciesVO> speciesVOS = new HashSet<>();
        for (Species s: species) {
            speciesVOS.add(convert(s));
        }
        return speciesVOS;
    }
}
